/**
 * @title HHUserEditForm.java 
 * @description 	用户编辑的表单验证类
 * @create 			2012-8-11 上午10:59:40 By xjiujiu
 * @package 		apps.admin.form
 * @copyright 		Copyright (c) 2011-2012 http://xyrj.hhtc.edu.cn.com. All right reserved
 * @version         $Id$
 * XYRJ-Java-Project
 */


package apps.admin.form;

import com.xyrj.core.HHObject;
import com.xyrj.core.HHPojo;
import com.xyrj.core.IHHForm;
import com.xyrj.exception.HHValidateException;
import com.xyrj.mvc.HHView;
import com.xyrj.utils.HHVerify;

/**
 * 用户编辑的表单验证类
 * @ClassName: HHEditUserForm 
 * @Description:
 * @author maoyun0903(maoyun19900818@163.com);
 * @date 2012-10-8 下午8:52:05 
 * @version V1.0
 */
public class HHEditUserForm extends HHObject implements IHHForm
{

	/**
	 * @Fields String _repassword 重复密码
	 */
	private String _repassword;
	
	/* (非 Javadoc) 
	 * <p>执行对应的验证条件</p>
	 * 
	 * <p>description: </p> 
	 *
	 * @title validate 
	 * @param  HHPojo pojo 发前需要验证的模块POJO信息对象
	 * @throws HHValidateException 
	 * @see com.xyrj.core.IHHForm#validate(com.xyrj.core.HHPojo) 
	 */
	@Override
	public void validate(HHPojo pojo) throws HHValidateException
	{
		if(true == HHVerify.isEmpty(pojo.getField("user_name"))) {
			throw new HHValidateException("用户名没有填写！");
		}
		if(false == HHVerify.checkStrLen((String)pojo.getField("user_name"), 2, 20)) {
			throw new HHValidateException("用户名长度不符！请参见说明信息～");
		}
		if(true == HHVerify.isEmpty(pojo.getField("user_truename"))) {
			throw new HHValidateException("真实姓名没有填写！");
		}
		if(false == HHVerify.checkStrLen((String)pojo.getField("user_truename"), 2, 20)) {
			throw new HHValidateException("真实姓名长度不符！请参见说明信息～");
		}
		if(false == HHVerify.isEmpty(pojo.getField("password"))) {
			if(false == HHVerify.checkStrLen((String)pojo.getField("password"), 6, 20)) {
				throw new HHValidateException("用户密码长度不符！请参见说明信息～");
			}
			if(!((String)pojo.getField("password")).equals(this._repassword)) {
				throw new HHValidateException("两次密码不一致！");
			}
		} else {
			pojo.deleteField("password");
		}
		if(true == HHVerify.isEmpty(pojo.getField("parent_id"))) {
			throw new HHValidateException("用户类型没有选择！");
		}
		if(true == HHVerify.isEmpty(pojo.getField("sex"))) {
			throw new HHValidateException("用户性别没有选择！");
		}
		if(true == HHVerify.isEmpty(pojo.getField("pass_flag"))) {
			throw new HHValidateException("是否审核通过没有选择！");
		}
	}

	/* (非 Javadoc) 
     * <p>非POJO表单信息提交验证</p>
     * 
     * <p>description: </p> 
     *
     * @title validate 
     * @param view
     * @throws HHValidateException 
     * @see com.xyrj.core.IHHForm#validate(com.xyrj.mvc.HHView) 
     */
    @Override
    public void validate(HHView view) throws HHValidateException
    {
    	//some code
    }

}
